package ouyangye;

//1.CDBG
//2.ABEFG
//3.AEF

public class Text {
    public static void main(String[] args) {
        double[] arr = new double[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = Math.random() * 10;
        }


        System.out.println("输出");
        for (double num : arr) {
            System.out.println(num);
        }

        // 静态内部类的静态方法获取最大值和最小值对象
        MaxAndMin.GetMinAndMax result = MaxAndMin.GetMinAndMax.getResult(arr);
        // 利用 getMin() 和 getMax() 方法获取并输出最小值和最大值
        System.out.println("最大值：" + result.getMax());
        System.out.println("最小值：" + result.getMin());
    }
}

class MaxAndMin {
    // 静态内部类
    static class GetMinAndMax {
        private double min;
        private double max;

        public GetMinAndMax(double min, double max) {
            this.min = min;
            this.max = max;
        }

        public double getMin() {
            return min;
        }

        public double getMax() {
            return max;
        }

        // 静态方法，包含最大和最小值的对象
        public static GetMinAndMax getResult(double[] arr) {
            double min = arr[0];
            double max = arr[0];
            for (double num : arr) {
                if (num < min) {
                    min = num;
                }
                if (num > max) {
                    max = num;
                }
            }
            return new GetMinAndMax(min, max);
        }
    }
}